import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

// var userId = JSON.parse(localStorage.getItem("user"));

export const constantRoutes = [{
    name: "Login",
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true,
    meta: {
      title: '登录页',
      // icon: 'el-icon-s-order',
    },
  },
  {
    path: '/',
    component: Layout,
    redirect: '/welcome',
    name: 'Welcome',
    hidden: true,
    meta: {
      title: '欢迎页',
      // icon: 'el-icon-s-order',

    },
    children: [{
      path: '/welcome',
      name: 'WelcomeC',
      component: () => import('../components/welcome/welcome.vue'),
      meta: {
        title: '欢迎页'
      }
    }]
  },
  // 基本信息管理
  {
    path: '/example',
    component: Layout,
    redirect: '/example/projectinfo',
    name: 'Example',
    meta: {
      title: '基本信息管理',
      icon: 'el-icon-s-order',

    },
    children: [{
      path: 'country',
      name: 'Country',
      component: () => import('../components/System/country.vue'),
      meta: {
        title: '乡设置'
      }
    }, {
      path: 'village',
      name: 'Village',
      component: () => import('../components/System/village.vue'),
      meta: {
        title: '村设置'
      }
    }, {
      path: 'benchmark',
      name: 'Benchmark',
      component: () => import('../components/Example/benchmark.vue'),
      meta: {
        title: '年度利率设置'
      }
    }, {
      //   path: 'insured',
      //   name: 'Insured',
      //   component: () => import('../components/Example/insured.vue'),
      //   meta: {
      //     title: '参保补贴设置'
      //   }
      // }, {
      path: 'wages',
      name: 'Wages',
      component: () => import('../components/Example/wages.vue'),
      meta: {
        title: '基准金额设置'
      }
    }, {
      path: '/example/projectinfo',
      name: 'Projectinfo',
      component: () => import('../components/Nested/projectinfo.vue'),
      meta: {
        title: '项目信息管理'
      }
    }, ]
  },
  // 人员信息管理
  {
    path: '/nested',
    component: Layout,
    redirect: '/nested/projectinfo',
    name: 'Nested',
    meta: {
      title: '人员信息管理',
      icon: 'el-icon-user-solid',
      role: ['admin']
    },
    // hidden:true,
    children: [{
        path: 'userinfo',
        name: 'Userinfo',
        component: () => import('../components/Nested/userinfo.vue'),
        meta: {
          title: '人员信息导入',
          role: ['admin']
        },
        // hidden:true
      }, {
        path: 'userinfoapply',
        name: 'Userinfoapply',
        component: () => import('../components/Nested/userinfoapply.vue'),
        meta: {
          title: '人员信息管理',
          role: ['admin']
        },
        // hidden:true
      }
      // , {
      //   path: 'userinfomodify',
      //   name: 'Userinfomodify',
      //   component: () => import('../components/Nested/userinfomodify.vue'),
      //   meta: {
      //     title: '人员信息更改'
      //   }
      // }, {
      //   path: 'cardnumberupdate',
      //   name: 'Cardnumberupdate',
      //   component: () => import('../components/Nested/cardnumberupdate.vue'),
      //   meta: {
      //     title: '银行卡号批量更新'
      //   }
      // }
    ]
  },
  // 账户管理
  {
    path: '/account',
    component: Layout,
    redirect: '/account/accountinfo',
    name: 'Account',
    meta: {
      title: '账户管理',
      icon: 'el-icon-s-finance',
      role: ['admin']
    },
    children: [{
        path: 'accountinfo',
        name: 'Accountinfo',
        component: () => import('../components/Account/accountinfo.vue'),
        meta: {
          title: '账户信息管理'
        }
      }, {
        path: 'accountinterestapply',
        name: 'Accountinterestapply',
        component: () => import('../components/Account/accountinterestapply.vue'),
        meta: {
          title: '账户计息申请'
        }
      }, {
        //   path: 'accountexpendregister',
        //   name: 'Accountexpendregister',
        //   component: () => import('../components/Expenditure/accountexpendregister.vue'),
        //   meta: {
        //     title: '账户支出登记（职保）'
        //   }
        // }, {
        path: 'accountexpend',
        name: 'Accountexpend',
        component: () => import('../components/Expenditure/accountexpend.vue'),
        meta: {
          title: '账户支出管理'
        }
      },
      //  {
      //   path: 'accountinfoadmin',
      //   name: 'Accountinfoadmin',
      //   component: () => import('../components/Account/accountinfoadmin.vue'),
      //   meta: {
      //     title: '账户信息管理（其他）'
      //   }
      // },
      // {
      //   path: 'accountoccupationadmin',
      //   name: 'Accountoccupationadmin',
      //   component: () => import('../components/Account/accountoccupationadmin.vue'),
      //   meta: {
      //     title: '账户信息管理（职保）'
      //   }
      // }, 
      {
        //   path: 'accountregister',
        //   name: 'Accountregister',
        //   component: () => import('../components/Expenditure/accountregister.vue'),
        //   meta: {
        //     title: '账户结算登记（职保）'
        //   }
        // }, {
        path: 'accountsettlement',
        name: 'Accountsettlement',
        component: () => import('../components/Expenditure/accountsettlement.vue'),
        meta: {
          title: '账户结算管理'
        }
      }, {
        path: 'accountcityadmin',
        name: 'Accountcityadmin',
        component: () => import('../components/Adjustment/admin.vue'),
        meta: {
          title: '账户调整管理'
        }
        //   // }, {
        //   path: 'accountsettlementcity',
        //   name: 'Accountsettlementcity',
        //   component: () => import('../components/Expenditure/accountsettlementcity.vue'),
        //   meta: {
        //     title: '账户结算申请（城居保）'
        //   }
      }
    ]
  },
  // 支出管理
  /*
   * {
   *  path: '/expenditure',
   *   component: Layout,
   *   redirect: '/expenditure/accountexpendregister',
   *   name: 'Expenditure',
   *   meta: {
   *     title: '支出管理',
   *     icon: 'el-icon-s-promotion'
   *   },
   *   children: []
   * },
   */
  // 业务审核
  {
    path: '/business',
    component: Layout,
    redirect: '/business/userbusiness',
    name: 'Business ',
    meta: {
      title: '业务审核',
      icon: 'el-icon-s-check'
    },
    children: [{
      path: 'userbusiness',
      name: 'Userbusiness',
      component: () => import('../components/Business/userbusiness.vue'),
      meta: {
        title: '人员信息审核'
      }
    }, {
      //   path: 'userinfobusiness',
      //   name: 'Userinfobusiness',
      //   component: () => import('../components/Business/userinfobusiness.vue'),
      //   meta: {
      //     title: '人员信息更改审核'
      //   }
      // }, {
      path: 'accountbusiness',
      name: 'Accountbusiness',
      component: () => import('../components/Business/accountbusiness.vue'),
      meta: {
        title: '账户计息审核'
      }
    }, {
      path: 'accountexpendbusiness',
      name: 'Accountexpendbusiness',
      component: () => import('../components/Business/accountexpendbusiness.vue'),
      meta: {
        title: '账户支出审核'
      }
    }, {
      path: 'accountsetbusiness',
      name: 'Accountsetbusiness',
      component: () => import('../components/Business/accountsetbusiness.vue'),
      meta: {
        title: '账户结算审核'
      }
      // }, {
      //   path: 'cityBao',
      //   name: 'cityBao',
      //   // component: () => import('../components/Business/accountsetbusiness.vue'),
      //   meta: {
      //     title: '账户结算审核（城居保）'
      //   }
    }, {
      path: 'accountadjbusiness',
      name: 'Accountadjbusiness',
      component: () => import('../components/Adjustment/examine.vue'),
      meta: {
        title: '账户调整审核'
      }
    }, ]
  },
  // 制单管理
  {
    path: '/voucherpreparation',
    component: Layout,
    redirect: '/voucherpreparation/accountsubsidy',
    name: 'Voucherpreparation ',
    meta: {
      title: '制单管理',
      icon: 'el-icon-s-open'
    },
    children: [{
      path: 'accountsubsidycity',
      name: 'Accountsubsidycity',
      component: () => import('../components/Voucherpreparation/accountsubsidycity.vue'),
      meta: {
        title: '账户补贴制单（城居保）'
      }
    }, {
      path: 'accountsubsidy',
      name: 'Accountsubsidy',
      component: () => import('../components/Voucherpreparation/accountsubsidy.vue'),
      meta: {
        title: '账户补贴制单（职保）'
      }
    }, {
      path: 'accountsubsidyocc',
      name: 'Accountsubsidyocc',
      component: () => import('../components/Voucherpreparation/accountsubsidyocc.vue'),
      meta: {
        title: '账户补贴制单（其他）'
      }
    }, {
      path: 'accountinterest',
      name: 'Accountinterest',
      component: () => import('../components/Voucherpreparation/accountinterest.vue'),
      meta: {
        title: '账户计息制单'
      }
    }, {
      path: 'accountexpend',
      name: 'Accountexpend',
      component: () => import('../components/Voucherpreparation/accountexpend.vue'),
      meta: {
        title: '账户支出制单'
      }
    }, {
      path: 'accountsetocc',
      name: 'Accountsetocc',
      component: () => import('../components/Voucherpreparation/accountsetocc.vue'),
      meta: {
        title: '账户结算制单'
      }
      // }, {
      //   path: 'accountsetcity',
      //   name: 'Accountsetcity',
      //   component: () => import('../components/Voucherpreparation/accountsetcity.vue'),
      //   meta: {
      //     title: '账户结算制单（城居保）'
      //   }
    }, {
      path: 'accountsetadjust',
      name: 'Accountsetadjust',
      component: () => import('../components/Adjustment/Voucher.vue'),
      meta: {
        title: '账户调整制单'
      }
    }]
  },
  // 财务管理
  {
    path: '/finance',
    component: Layout,
    redirect: '/finance/accountsubsidy',
    name: 'Finance ',
    meta: {
      title: '财务管理',
      icon: 'el-icon-s-grid'
    },
    children: [{
        path: 'accountsubsidycity',
        name: 'Accountsubsidycity',
        component: () => import('../components/Finance/accountsubsidycity.vue'),
        meta: {
          title: '账户补贴到账（城居保）'
        }
      }, {
        path: 'accountsubsidyocc',
        name: 'Accountsubsidyocc',
        component: () => import('../components/Finance/accountsubsidyocc.vue'),
        meta: {
          title: '账户补贴到账（职保）'
        }
      },
      {
        path: 'accountsubsidy',
        name: 'Accountsubsidy',
        component: () => import('../components/Finance/accountsubsidy.vue'),
        meta: {
          title: '账户补贴到账（其他）'
        }
      },
      {
        path: 'accountinterest',
        name: 'Accountinterest',
        component: () => import('../components/Finance/accountinterest.vue'),
        meta: {
          title: '账户计息到账'
        }
      }, {
        path: 'accountexpend',
        name: 'Accountexpend',
        component: () => import('../components/Finance/accountexpend.vue'),
        meta: {
          title: '账户支出到账'
        }
      }, {
        path: 'accountsetocc',
        name: 'Accountsetocc',
        component: () => import('../components/Finance/accountsetocc.vue'),
        meta: {
          title: '账户结算到账'
        }
        // }, {
        //   path: 'accountsetcity',
        //   name: 'Accountsetcity',
        //   component: () => import('../components/Finance/accountsetcity.vue'),
        //   meta: {
        //     title: '账户结算到账（城居保）'
        //   }
        // }, {
        //   path: 'accountbusiness',
        //   name: 'Accountbusiness',
        //   component: () => import('../components/Finance/accountbusiness.vue'),
        //   meta: {
        //     title: '账户核算'
        //   }
      }, {
        path: 'accountadjust',
        name: 'Accountadjust',
        component: () => import('../components/Adjustment/Arrival.vue'),
        meta: {
          title: '账户调整到账'
        }
      }
    ]
  },
  // 查询统计
  // {
  //   path: '/query',
  //   component: Layout,
  //   redirect: '/query/approval',
  //   name: 'Query ',
  //   meta: {
  //     title: '查询统计',
  //     icon: 'el-icon-s-data'
  //   },
  //   children: [{
  //     path: 'approval',
  //     name: 'Approval',
  //     component: () => import('../components/Query/approval.vue'),
  //     meta: {
  //       title: '征地批文查询'
  //     }
  //   }, {
  //     path: 'user',
  //     name: 'User',
  //     component: () => import('../components/Query/user.vue'),
  //     meta: {
  //       title: '征地人员统计'
  //     }
  //   }, {
  //     path: 'account',
  //     name: 'Account',
  //     component: () => import('../components/Query/account.vue'),
  //     meta: {
  //       title: '征地账户查询'
  //     }
  //   }, {
  //     path: 'operation',
  //     name: 'Operation',
  //     component: () => import('../components/Query/operation.vue'),
  //     meta: {
  //       title: '操作历史查询'
  //     }
  //   }, {
  //     path: 'expenditure',
  //     name: 'Expenditure',
  //     component: () => import('../components/Query/expenditure.vue'),
  //     meta: {
  //       title: '支出制单查询'
  //     }
  //   }]
  // },
  // 系统管理
  {
    path: '/system',
    component: Layout,
    redirect: '/system/operation',
    name: 'System',
    meta: {
      title: '系统管理',
      icon: 'el-icon-s-tools'
    },
    children: [{
      path: 'operation',
      name: 'Operation',
      component: () => import('../components/System/operation.vue'),
      meta: {
        title: '操作员管理'
      }
    }, {
      //   path: 'jurisdiction',
      //   name: 'Jurisdiction',
      //   component: () => import('../components/System/jurisdiction.vue'),
      //   meta: {
      //     title: '权限管理'
      //   }
      // }, {
      //   path: 'sex',
      //   name: 'Sex',
      //   component: () => import('../components/System/sex.vue'),
      //   meta: {
      //     title: '性别'
      //   }
      // }, {
      //   path: 'country',
      //   name: 'Country',
      //   component: () => import('../components/System/country.vue'),
      //   meta: {
      //     title: '乡设置'
      //   }
      // }, {
      //   path: 'village',
      //   name: 'Village',
      //   component: () => import('../components/System/village.vue'),
      //   meta: {
      //     title: '村设置'
      //   }
      // }, {
      path: 'setting',
      name: 'Setting',
      component: () => import('../components/System/setting.vue'),
      meta: {
        title: '角色管理'
      }
    }, {
      //   path: 'permissions',
      //   name: 'Permissions',
      //   component: () => import('../components/System/permissions.vue'),
      //   meta: {
      //     title: '角色权限'
      //   }
      // }, {
      path: 'operations',
      name: 'Operations',
      component: () => import('../components/Query/operation.vue'),
      meta: {
        title: '操作历史查询'
      }
    }]
  },
]
// const user = localStorage.getItem('user');
// console.log(user);
// if (user != 'admin' & user != null) {
//   const aryRoute = JSON.parse(localStorage.getItem('aryRoute')); // 二级路由
//   const RouteList = JSON.parse(localStorage.getItem('routeList')) ? JSON.parse(localStorage.getItem('routeList')) : []; // 一级路由
//   console.log(RouteList);
//   let arr = [];
//   RouteList.map((item, index) => {
//     // console.log(item);
//     arr.push(item.ModelName);
//     // console.log(arr);
//   })
//   console.log(arr);
//   constantRoutes.map((item, index) => {
//     if (item.path != '/login') {
//       // console.log(item);
//       if (!arr.includes(item.meta.title)) {
//         item.hidden = true
//       }
//     } else {
//       item.hidden = false;
//     }
//   })
// }

// export const conRoutes = [{
//     name: "404",
//     path: '/404',
//     component: () => import('@/views/404'),
//     hidden: true
//   },
//   {
//     name: "404",
//     path: '*',
//     redirect: '/404',
//     hidden: true
//   }
// ];

// conRoutes.map((item, index) => {
//   constantRoutes.push(item);
// })
// constantRoutes.unshift(login)

const createRouter = () =>
  new Router({
    mode: 'hash',
    scrollBehavior: () => ({
      y: 0
    }),
    routes: constantRoutes
  })
const router = createRouter()
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}
localStorage.setItem("st", JSON.stringify(constantRoutes));

export default router
